<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/velocity/1.2.3/velocity.min.js"></script>
</head>

<body>
  <!-- 利用js和第三方js动画插件 实现组件动画 -->
  <div id="app">
    <button @click="show=!show">按钮</button>
    <transition @before-enter="beforeEnter" @enter="enter" @leave="leave" :css="false">
      <p v-if="show">hello vue</p>
    </transition>
  </div>
  <script>
    var app = new Vue({
      el: '#app',
      data: {
        show: false
      },
      methods: {
        beforeEnter: function (el) {
          el.style.transformOrigin = 'left'
        },
        enter: function (el, done) {
          Velocity(el, { opacity: 1, fontSize: '1.4em' }, { duration: 300 })
          Velocity(el, { fontSize: '1em' }, { complete: done })
        },
        leave: function (el, done) {
          Velocity(el, {
            translateX: '80px',
            rotateZ: '50deg'
          }, { duration: 600 })
          Velocity(el, {
            translateY: '80px',
            translateX: '150px',
            opacity: 0
          }, { complete: done })
        }
      }
    })
  </script>
</body>

</html>